package com.play.ballen.home.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.play.ballen.R
import com.play.ballen.home.entity.HomeBannerInfo
import com.yuven.appframework.util.imageloader.ImageUtil
import com.yuven.appframework.widget.banner.adapter.BannerAdapter
import com.yuven.appframework.widget.banner.util.BannerUtils

class MyBannerAdapter(banners: List<HomeBannerInfo>) :
    BannerAdapter<HomeBannerInfo, MyBannerAdapter.ImageHolder>(banners) {

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ImageHolder {
        val imageView = BannerUtils.getView(parent!!, R.layout.banner_image)
        return ImageHolder(imageView)
    }

    override fun onBindView(holder: ImageHolder, data: HomeBannerInfo, position: Int, size: Int) {
        ImageUtil.instance.loadImage(
            0,
            0,
            data.pic,
            holder.imageView
        )
    }

    class ImageHolder(view: View) : RecyclerView.ViewHolder(view) {
        var imageView: ImageView

        init {
            imageView = view as ImageView
        }
    }
}